package com.gzc.just.play.last.war.centralserver.match.model;

import java.util.HashSet;
import java.util.Set;

public class MatchTeam {
    private long teamId;
    private long leaderId;
    private String teamName;
    private MatchType matchType;
    private int maxMembers;
    private Set<Long> members;
    private long createTime;
    
    public MatchTeam() {
        this.members = new HashSet<>();
        this.createTime = System.currentTimeMillis();
    }
    
    // Getters and Setters
    public long getTeamId() {
        return teamId;
    }
    
    public void setTeamId(long teamId) {
        this.teamId = teamId;
    }
    
    public long getLeaderId() {
        return leaderId;
    }
    
    public void setLeaderId(long leaderId) {
        this.leaderId = leaderId;
    }
    
    public String getTeamName() {
        return teamName;
    }
    
    public void setTeamName(String teamName) {
        this.teamName = teamName;
    }
    
    public MatchType getMatchType() {
        return matchType;
    }
    
    public void setMatchType(MatchType matchType) {
        this.matchType = matchType;
    }
    
    public int getMaxMembers() {
        return maxMembers;
    }
    
    public void setMaxMembers(int maxMembers) {
        this.maxMembers = maxMembers;
    }
    
    public Set<Long> getMembers() {
        return new HashSet<>(members);
    }
    
    public boolean addMember(long userId) {
        return members.add(userId);
    }
    
    public boolean removeMember(long userId) {
        return members.remove(userId);
    }
    
    public boolean hasMember(long userId) {
        return members.contains(userId);
    }
    
    public boolean isFull() {
        return members.size() >= maxMembers;
    }
    
    public int getCurrentMemberCount() {
        return members.size();
    }
    
    public int getRemainingSlots() {
        return maxMembers - members.size();
    }
    
    public long getCreateTime() {
        return createTime;
    }
    
    public void setCreateTime(long createTime) {
        this.createTime = createTime;
    }
    
    @Override
    public String toString() {
        return "MatchTeam{" +
                "teamId=" + teamId +
                ", leaderId=" + leaderId +
                ", teamName='" + teamName + '\'' +
                ", matchType=" + matchType +
                ", members=" + members.size() + "/" + maxMembers +
                '}';
    }
}
